Runtime Reconfiguration Pattern

This document describes the Runtime Reconfiguration Pattern example from the guide Cloud Design Patterns (see http://aka.ms/Cloud-Design-Patterns).

 


 

Before you start

 

Ensure that you have installed all of the software prerequisites. For details see the Release Notes.

 

The example demonstrates operational aspects of applications running in Windows Azure. Therefore, you will need to use the diagnostics tools in order to understand how the code sample works. You must ensure that the web and worker roles in the solution are configured to use the diagnostics mechanism. If not, you will not see the trace information generated by the example.

 


 

About the Example

 

This example shows how a change in the settings of a Cloud Service can be applied without restarting the web or worker role. The relevant code is in the files Global.asax.cs and WebRole.cs.

 


 

Running the Example

 

You can run this example locally in the Visual Studio Windows Azure emulator. You can also run this example by deploying it to a Windows Azure Cloud Service.

 

  • Start Visual Studio using an account that has Administrator privileges ("Run as Administrator").
  • Open the solution you want to explore from the subfolders where you downloaded the examples.
  • Right-click on each role in Solution Explorer, select Properties, and ensure that the role is configured to generate diagnostic information.

  • If you want to run the example in the local Windows Azure emulator:
    • Start the application without debugging by selecting Start Without Debugging from the DEBUG menu.
    • In the folder samples-folder\RuntimeReconfiguration\bin\Debug (where samples-folder is the folder where you installed the examples) open the file ServiceConfiguration.cscfg in Visual Studio or in a text editor.
    • Change the value of the setting named CustomSetting to a different value.
    • To indicate to the emulator that the configuration has changed, open a Windows Azure Command Prompt from the Windows Start screen or Apps page.
    • In Command Prompt type the command csrun /status and make a note of the value of Deployment-Id.
    • In Command Prompt type the following command on one line:
        csrun /update:deployment-id;samples-folder\RuntimeReconfiguration\bin\Debug\ServiceConfiguration.cscfg
      replacing deployment-id and samples-folder with your own values.
    • Wait for a few seconds to allow the reconfiguration to complete.
    • In the browser, view the values that were updated without restarting the application. Note that, due to some issues with the compute emulator, the first time you run execute the csrun /update command it will restart the instance. After that it will re-configure the application without restarting it.
  • If you want to run the example on Windows Azure:
    • Deploy the application to Windows Azure from Visual Studio and start it running.
    • Open the Windows Azure portal, sign into your subscription, and select the Cloud Service where you deployed the application.
    • Using the portal to change the value of the setting named CustomSetting in the service configuration to a different value.
    • Wait for a few seconds to allow the reconfiguration to complete.
    • In the browser, view the values that were updated without restarting the application.